/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.openbrew.openbrewrf;

import com.openbrew.openbrewrf.views.FGIView;
import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author chapmand
 */
@Entity
@Table(name = "PSOLines")
@XmlRootElement
public class PSOLines implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "psoID")
    private Integer psoid;
    @Basic(optional = false)
    @NotNull
    @Column(name = "psoQty")
    private int psoqty;
    @Basic(optional = false)
    @NotNull
    @Column(name = "psoSold")
    private boolean psosold;
    @Basic(optional = false)
    @NotNull
    @Column(name = "psoKeg")
    private int psokeg;
    @Basic(optional = false)
    @NotNull
    @Column(name = "psoPriceOver")
    private float psopriceover;
    @Basic(optional = false)
    @NotNull
    @Column(name = "psoQtyLeft")
    private int psoqtyleft;
    @JoinColumn(name = "psoFGI", referencedColumnName = "FGIID")
    @ManyToOne(optional = false)
    private FGIView psofgi;
    @JoinColumn(name = "psoDisc", referencedColumnName = "DiscID", nullable=true)
    @ManyToOne(optional = false)
    private DiscountCode psodisc;

    public PSOLines() {
    }

    public PSOLines(Integer psoid) {
        this.psoid = psoid;
    }

    public PSOLines(Integer psoid, int psoqty, boolean psosold, int psokeg, float psopriceover) {
        this.psoid = psoid;
        this.psoqty = psoqty;
        this.psosold = psosold;
        this.psokeg = psokeg;
        this.psopriceover = psopriceover;
    }

    public Integer getPSOID() {
        return psoid;
    }

    public void setPSOID(Integer psoid) {
        this.psoid = psoid;
    }
    
    public int getPSOQty(){
        return psoqty;
    }
    
    public void setPSOQty(int psoqty){
        this.psoqty = psoqty;
    }
    
    public boolean getPSOSold(){
        return psosold;
    }
    
    public void setPSOSold(boolean psosold){
        this.psosold = psosold;
    }
    
    public int getPSOKeg(){
        return psokeg;
    }
    
    public void setPSOKeg(int psokeg){
        this.psokeg = psokeg;
    }
    
    public float getPSOPriceOverRide(){
        return psopriceover;
    }
    
    public void setPSOPriceOverRide(float psopriceover){
        this.psopriceover = psopriceover;
    }
    
    public int getPSOQtyLeft(){
        return psoqtyleft;
    }
    
    public void setPSOQtyLeft(int psoqtyleft){
        this.psoqtyleft = psoqtyleft;
    }
    
    public FGIView getPSOFGI(){
        return psofgi;
    }
    
    public void setPSOFGI(FGIView psofgi){
        this.psofgi = psofgi;
    }
    
    public DiscountCode getPSODiscCode(){
        return psodisc;
    }
    
    public void setPSODiscCode(DiscountCode psodisc){
        if(psodisc.getDiscID()!=null){
            this.psodisc = psodisc;
        }
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (psoid != null ? psoid.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Sales)) {
            return false;
        }
        PSOLines other = (PSOLines) object;
        if ((this.psoid == null && other.psoid != null) || (this.psoid != null && !this.psoid.equals(other.psoid))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.openbrew.openbrewrf.Sales[ sId=" + psoid + " ]";
    }
}
